package com.cy.pj.sys.web.controller;

import com.cy.common.util.PageUtil;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import com.cy.pj.sys.web.pojo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log/")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @GetMapping
    public JsonResult doSelectLogs(SysLog sysLog){


        /**
         * PageInfo<SysLog> pageInfo.PageUtil.startPage()  //启动分页查询拦截
         *                             .doSelectPageInfo(()->  //查询分页数据
         *                 sysLogService.selectLogs(sysLog)
         *
         *
         *
         *
         *
         * 套用分页查询数据,利用PageUtil工具类方法和lamba表达式
         *
         * 查询结果底层会存储到pageInfo中因为使用了mybatis的pagehelper插件
         */
        return new JsonResult(PageUtil.startPage()  //启动分页查询拦截
                            .doSelectPageInfo(()->  //查询分页数据
                sysLogService.selectLogs(sysLog)    //
            ));
    }
        @GetMapping("{id}")
        public JsonResult doFindById(@PathVariable Long id){
            return new JsonResult(sysLogService.selectById(id));
        }

        @DeleteMapping("{ids}")
        public JsonResult doDeleteById(@PathVariable Long... ids){
            sysLogService.deleteLog(ids);
            return new JsonResult("delete ok");
        }





}

